package daylight;

import java.io.FileNotFoundException;
import java.io.PrintStream;

public class 打印流 {//方便记录数据(日志)
    public static void main(String[] args) throws FileNotFoundException {
        PrintStream printStream = new PrintStream("DAY12\\zz.txt");
        printStream.println("hello");
        printStream.println('a');
        printStream.println(123);
        System.out.println(123);//
        System.setOut(new PrintStream("DAY12\\dd.txt"));//改变系统输出流向
        System.out.println(123456);
        int[] ints = new int[3];
        try {
            System.out.println(ints[3]);//会将异常抛出
        } catch (ArrayIndexOutOfBoundsException e) {
            System.out.println(e.toString());//将异常打印到指定文件夹(日志)
        }
    }
}
